const start = () => {
    console.log('---- start ----: ', 'serviceWorker' in navigator);
    if ('serviceWorker' in navigator) {
        navigator.serviceWorker
            .register('./sw-test.js', { scope: '/sw-test/' })
            .then(function(reg) {
                if (reg.installing) {
                    console.log('Service worker installing');
                } else if (reg.waiting) {
                    console.log('Service worker installed');
                } else if (reg.active) {
                    console.log('Service worker active');
                }
            })
            .catch(function(error) {
                // registration failed
                console.log('Registration failed with ' + error);
            });
    }
};

start();
